
#include "cocos-ext.h"

#include "Common/Exd/EXData.h"
#include "StageSelectScene.h"
#include "MainMenuScene.h"
#include "StageScene.h"

USING_NS_CC;
USING_NS_CC_EXT;

StageSelectScene::StageSelectScene(bool bPortrait )
{
    CCScene::init();

}


void StageSelectScene::CreateMenu(const char* title, SEL_MenuHandler handler, const CCPoint& pos , int childtag)
{
    CCLabelTTF* label = CCLabelTTF::create(title, "Arial", 20);
    CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, handler);

    CCMenu* pMenu =CCMenu::create(pMenuItem, NULL);
    pMenu->setPosition( CCPointZero );
	pMenuItem->setPosition( pos );
    addChild(pMenu, childtag);
}



void StageSelectScene::onEnter()
{
    CCScene::onEnter();


	UILayer* ul =UILayer::create();
	ul->addWidget(CCUIHELPER->createWidgetFromJsonFile("UI/StageSelect.json"));
    addChild(ul, 1);


	UIButton* playShapeBtn = (UIButton*)ul->getWidgetByTag(49);
	//playShapeBtn->addReleaseEvent(this, menu_selector(StageSelectScene::PlayShapCallback) );
	playShapeBtn->setPressedActionEnabled(true);


	UIButton* playColorBtn = (UIButton*)ul->getWidgetByTag(50);
	playColorBtn->addReleaseEvent(this, menu_selector(StageSelectScene::PlayColorCallback) );
	playColorBtn->setPressedActionEnabled(true);

	UIButton* playNumberBtn = (UIButton*)ul->getWidgetByTag(51);
	playNumberBtn->addReleaseEvent(this, menu_selector(StageSelectScene::PlayNumberCallback) );
	playNumberBtn->setPressedActionEnabled(true);

	UIButton* playShapeColorBtn = (UIButton*)ul->getWidgetByTag(54);
	playShapeColorBtn->addReleaseEvent(this, menu_selector(StageSelectScene::PlayShapColorCallback) );
	playShapeColorBtn->setPressedActionEnabled(true);

	UIButton* playShapeNumberBtn = (UIButton*)ul->getWidgetByTag(56);
	playShapeNumberBtn->addReleaseEvent(this, menu_selector(StageSelectScene::PlayShapNumberCallback) );
	playShapeNumberBtn->setPressedActionEnabled(true);

	UIButton* playColorNumberBtn = (UIButton*)ul->getWidgetByTag(55);
	playColorNumberBtn->addReleaseEvent(this, menu_selector(StageSelectScene::PlayColorNumberCallback) );
	playColorNumberBtn->setPressedActionEnabled(true);

	UIButton* playColorShapeNumberBtn = (UIButton*)ul->getWidgetByTag(53);
	playColorShapeNumberBtn->addReleaseEvent(this, menu_selector(StageSelectScene::PlayColorNumberShapCallback) );
	playColorShapeNumberBtn->setPressedActionEnabled(true);

	UIButton* backBtn = (UIButton*)ul->getWidgetByTag(24);
	backBtn->addReleaseEvent(this, menu_selector(StageSelectScene::BackCallback) );
	backBtn->setPressedActionEnabled(true);



	//playColorBtn->disable();

}

// The CallBack for back to the main menu scene
void StageSelectScene::BackCallback(CCObject* pSender)
{
	MainMenuScene* selectScn = new MainMenuScene;
	CCDirector::sharedDirector()->replaceScene(CCTransitionCrossFade::create(1,selectScn ));
}



void StageSelectScene::PlayShapCallback(CCObject* pSender)
{
	StageScene* stageScn = new StageScene(1);
	CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(1,stageScn ));
}


void StageSelectScene::PlayColorCallback(CCObject* pSender)
{

	StageScene* stageScn = new StageScene(2);
	CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(1,stageScn ));
}



void StageSelectScene::PlayNumberCallback(CCObject* pSender)
{
	StageScene* stageScn = new StageScene(3);
	CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(1,stageScn ));
}


void StageSelectScene::PlayShapColorCallback(CCObject* pSender)
{
	StageScene* stageScn = new StageScene(4);
	CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(1,stageScn ));
}

void StageSelectScene::PlayShapNumberCallback(CCObject* pSender)
{
	StageScene* stageScn = new StageScene(5);
	CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(1,stageScn ));
}

void StageSelectScene::PlayColorNumberCallback(CCObject* pSender)
{
	StageScene* stageScn = new StageScene(6);
	CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(1,stageScn ));
}

void StageSelectScene::PlayColorNumberShapCallback(CCObject* pSender)
{
	StageScene* stageScn = new StageScene(7);
	CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(1,stageScn ));
}





